package com.shen.JUC.Lock8;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ReenLock {
    public static void main(String[] args) {
        //可重用锁
        Phone5 phone = new Phone5();
        new Thread(()->{
            phone.send();
        },"A").start();
        new Thread(()->{
            phone.send();
        },"B").start();
    }
}

class Phone5{
//lock锁的话有2把锁，并且必须配对
  Lock lock=new ReentrantLock();

    public synchronized void send(){

        System.out.println(Thread.currentThread().getName()+" send");
        call();
    }
    public synchronized void call(){
        System.out.println(Thread.currentThread().getName()+" call");
    }
}